package org.tech4j.schedule.powerjob;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tech4j.common.utils.JsonUtils;
import org.tech4j.edi.schedule.common.ScanRetryService;
import org.tech4j.edi.schedule.common.entity.ScanEntity;
import tech.powerjob.worker.core.processor.ProcessResult;
import tech.powerjob.worker.core.processor.TaskContext;
import tech.powerjob.worker.core.processor.sdk.BasicProcessor;

/**
 * @program: tech4j
 * @description:
 * @author: YuKai Fan
 * @create: 2025/3/10 09:10
 **/
public class ScanRetryJobHandler implements BasicProcessor {
    private final static Logger log = LoggerFactory.getLogger(ScanRetryJobHandler.class);

    private final ScanRetryService scanRetryService;

    public ScanRetryJobHandler(ScanRetryService scanRetryService) {
        this.scanRetryService = scanRetryService;
    }

    @Override
    public ProcessResult process(TaskContext taskContext) throws Exception {
        DefaultScanEntity scanEntity = new DefaultScanEntity();
        log.info("{} 处理开始 params={}", "SliceScanRetryJobHandler", JsonUtils.toJsonString(scanEntity));
        scanRetryService.scanRetry(scanEntity);
        log.info("{} 处理结束", "SliceScanRetryJobHandler");
        return new ProcessResult(true);
    }

    private static class DefaultScanEntity implements ScanEntity {
    }
}
